#! /usr/bin/python

import calendar
import string
import re
import datetime

def getYear(cyear=2007):
    calendar.prcal(cyear)
    
def getMnth(cyear=2007, cmonth=3):
    calendar.prmonth(cyear,cmonth) 

def isWeekend(inDateIso_s):
    in_l = string.split(inDateIso_s,'-')
    wday = datetime.date(   int(in_l[0]), int(in_l[1]), int(in_l[2])
                    ).isoweekday()
    if wday in (6,7):
        return (True, wday)
    else:
        return (False, wday)

holidays_s = re.sub('\t', '', open('C:/AFT/pepe/calendarx/HOLIDAYS/data.txt','r').read())
holidays_l = string.split(holidays_s,'\n')
#print holidays_l

def isHoliday(in_s, countryDomainCode_s):
    ish = 0
    for day_s in holidays_l:
        if  countryDomainCode_s == day_s[:2] \
            and in_s == day_s[3:]:
                ish = 1
    if ish == 1:
        return True
    else:
        return False

def main():
    #getYear()
    #getYear(2008)
    #getYear(2006)
    #getMnth(2007, cmonth=6)
    print "isWeekend('2007-05-11')", isWeekend('2007-05-11')
    print "isWeekend('2007-06-16')", isWeekend('2007-06-16')
    print "isWeekend('2007-06-17')", isWeekend('2007-06-17')
    print "isWeekend('2007-06-18')", isWeekend('2007-06-18')
    print "isHoliday('2007-05-08', 'sk')", isHoliday('2007-05-08', 'sk')

if __name__ == "__main__":
    main()
